#!/usr/bin/python

import sys
import Image

def vertical_filter(inf, outf):
	im = Image.open(inf)
        nim = im.copy()
        (width, height) = im.size

	#[1,0,-1]
	pix = nim.load()
	for x in range(width):
		for y in range(1,height-1):
			pix[x,y] = abs(pix[x, y-1] - pix[x, y+1])
	
	nim.save(outf)
	
if __name__ == '__main__':
        argvs = sys.argv
        argc  = len(argvs)
        if ( argc != 2 ):
                print "Usage: tool <FileName>"
                sys.exit(1)
        vertical_filter(argvs[1], '/tmp/result.pgm')




	
